﻿#include "ssTerrain10Material.h"

namespace StarSeeker
{

ssTerrain10Material::ssTerrain10Material()
{
	m_baseHeightVal = 0.f;
	m_heightScale = 0.f;
	m_XLength = 0.f;
	m_YLength = 0.f;
	m_hWidth.BindData(SS_GL_UNIFORM_FLOAT, "cm_XLength");
	m_hHeight.BindData(SS_GL_UNIFORM_FLOAT, "cm_YLength");
	m_hBaseHeightVal.BindData(SS_GL_UNIFORM_FLOAT, "cm_BaseHeight");
	m_hHeightScale.BindData(SS_GL_UNIFORM_FLOAT, "cm_HeightScale");
}

ssTerrain10Material::~ssTerrain10Material()
{
}

void ssTerrain10Material::Init(ssShader* ps, ssfloat baseHeightVal, ssfloat heightScale, ssfloat XLength, ssfloat YLength)
{
	m_baseHeightVal = baseHeightVal;
	m_heightScale = heightScale;
	m_XLength = XLength;
	m_YLength = YLength;
	SetShader(ps);
}

void ssTerrain10Material::BindTexture2DShaderUniform()
{
	m_shaderTexture.Resize(3);
	m_shaderTexture.SetCount(3);
	m_shaderTexture[0].BindData(SS_GL_UNIFORM_TEX2D, "cm_hightMap");
	m_shaderTexture[1].BindData(SS_GL_UNIFORM_TEX2D, "cm_map1");
	m_shaderTexture[2].BindData(SS_GL_UNIFORM_TEX2D, "cm_map2");
}

void ssTerrain10Material::OnRenderBegin()
{
	m_hWidth.Use(m_pShader, &m_XLength, 1);
	m_hHeight.Use(m_pShader, &m_YLength, 1);
	m_hBaseHeightVal.Use(m_pShader, &m_baseHeightVal, 1);
	m_hHeightScale.Use(m_pShader, &m_heightScale, 1);

	//m_pShader->SetTextureUniformVariables(0, "cm_hightMap");
	//m_pShader->SetTextureUniformVariables(1, "cm_map1");
	//m_pShader->SetTextureUniformVariables(2, "cm_map2");
	ssTextureMaterial::OnRenderBegin();
}

}
